
<template>
  <div class="home">
    <el-container>
      <MyAside :isShow="isShow"></MyAside>
      <el-container>
        <el-header :style="{ background: this.$store.state.color }">
          <i v-if="isShow" @click="changeAside" class="el-icon-s-fold"></i>
          
          <i v-else @click="changeAside" class="el-icon-s-unfold"></i>
          <el-avatar icon="el-icon-user-solid"></el-avatar>
        </el-header>
        <el-main :style="{ background: this.$store.state.bodycolor }">
          <!-- 面包屑 -->
          <el-breadcrumb separator=" ">
            <el-breadcrumb-item
              :key="index"
              v-for="(item,index) in $store.state.abcList"
              :to="{ path: item.track }"
            >
              <el-tag
                :class="{activeColor:$store.state.abcnum===index}"
                @click="changeColor(item,index)"
                :key="index"
                closable
                :type="item.type"
                :disable-transitions="false"
                @close="handleClose(item)"
              >{{ item.name }}</el-tag>
            </el-breadcrumb-item>
          </el-breadcrumb>

          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import store from "@/store/index";
import MyAside from "@/views/HomeComponents/MyAside";
import { finds } from "../utils";
export default {
  data() {
    return {
      // 定义一个状态用于控制左侧侧边栏的展开和收起
      isShow: true,
     
    };
  },
  methods: {
    // 更改侧边栏状态
    changeAside() {
      this.isShow = !this.isShow;
    },
    handleClose(flag) {
      if(flag.track=='/home/index') return

      
      // console.log(this.$store);
      let num = finds(store.state.abcList, flag);
      this.$store.commit("checked", num);
      this.$router.push('/home/index')
      store.commit("setAbcnum",0 );

    },
    changeColor(item, index) {
      store.commit("setAbcnum",index );
      this.colorIndex=  store.state.abcnum
    }
  },
  components: {
    MyAside
  }
};
</script>




<style scoped lang="scss">
.home {
  width: 100%;
  height: 100%;
  .el-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .el-aside {
    color: #ffffff;
  }
  .el-header {
    background: rgb(67, 56, 202);
  }
  .el-header,
  .el-aside {
    background-color: rgb(4, 49, 42);
    color: #ffffff;
  }

  .el-main {
    background-color: #e9eef3;
    color: #333;
    text-align: center;
  }

  .el-container {
    height: 100%;
  }
  .el-tag {
    width: 90px;
    height: 35px;
    text-align: center;
    line-height: 35px;
  }
    .activeColor {
    color: #f18a02;
    background-color: RGB(236,245,255);
  }
}
</style>
